//
//  StatusCellBottomView.swift
//  Weibo
//
//  Created by 张婷 on 15/10/26.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
    
    ///  MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /// MARK: - 懒加载控件
    // 转发按钮
    private var retweetButton: UIButton = UIButton(title: " 转发",
        fontSize: 12,
        color: UIColor.lightGrayColor(),
        imageName: "timeline_icon_retweet")
    /// 评论按钮
    private var commentButton: UIButton = UIButton(title: " 评论",
        fontSize: 12,
        color: UIColor.lightGrayColor(),
        imageName: "timeline_icon_comment")
    /// 点赞按钮
    private var likeButton: UIButton = UIButton(title: " 点赞",
        fontSize: 12,
        color: UIColor.lightGrayColor(),
        imageName: "timeline_icon_unlike")
}

// MARK: - 页面设置
extension StatusCellBottomView {
    
    private func setupUI() {
        
        // 0. 背景颜色
        backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        // 1. 添加控件
        addSubview(retweetButton)
        let sep1 = sepView()
        addSubview(sep1)
        addSubview(commentButton)
        
        let sep2 = sepView()
        addSubview(sep2)
        addSubview(likeButton)
        
        // 2. 添加约束
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.top.equalTo(retweetButton.snp_top)
            make.width.equalTo(retweetButton.snp_width)
            make.height.equalTo(retweetButton.snp_height)
        }
        
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(commentButton.snp_top)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            
            make.right.equalTo(self.snp_right)
        }
        
        sep1.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(0.5)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(0.4)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(sep1.snp_width)
            make.height.equalTo(sep1.snp_height)
        }
        
    }
    
    ///  分割线视图
    ///
    ///  - returns: <#return value description#>
    private func sepView() -> UIView {
        let view = UIView()
        view.backgroundColor = UIColor.lightGrayColor()
        return view
    }
}
